﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;

namespace ShowSystem
{
    class BackGround:OneFrame2D 
    {
        float dx;
        float dy;
        Vector2 finalPos;
        float finScale=1;
        float dscale;
        float time=100;

        public BackGround(Texture2D texture,Vector2 initPos,Vector2 finPos)
            : base(texture)
        {
            this.Position = initPos;
            finalPos = finPos;
            Scale = 0;
            dx = (initPos.X  -finPos .X )/time ;
            dy =(initPos.Y  - finPos.Y )/time ;
        }
        public BackGround(Texture2D texture, Vector2 initPos, Vector2 finPos, float scale0, float scale1)
            : base(texture)
        {
            this.Position = initPos;
            finalPos = finPos;
            Scale = scale0 ;
            finScale = scale1;
            dx = (initPos.X - finPos.X ) / time ;
            dy = (initPos.Y - finPos.Y) / time ;
            dscale = (finScale - Scale) / time ;
        }

        public override void Update(GameTime gameTime)
        {
            if (Scale < finScale )
                Scale += dscale ;
            if (Position.X - finalPos.X > Math.Abs(dx))
                Position = new Vector2(Position.X - dx, Position.Y);
            else Position = new Vector2 ( finalPos.X,Position .Y );
            if (Position.Y - finalPos.Y > Math.Abs(dy))
                Position = new Vector2(Position.X, Position.Y - dy);
            else Position = new Vector2( Position.X ,finalPos .Y );

            base.Update(gameTime);
        }
    }
}
